$(function () {
    //获取当前网址，如： http://localhost:8083/myproj/view/my.jsp
    var curWwwPath=window.document.location.href;
    //获取主机地址之后的目录，如： myproj/view/my.jsp
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPaht=curWwwPath.substring(0,pos);
    //获取带"/"的项目名，如：/myproj
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    //得到了 http://localhost:8083/myproj
    var realPath=localhostPaht+projectName;
    $.ajax({
        url: realPath+"/news/list",
        data: {"page":0,"size":6},
        dataType: "json",
        type: 'POST',
        success: function(data) {

            var list = data.data.content;
            var str="<div style='width: 100%;height: 40px;float: left;background: #8a6d3b'><h3 style='margin: 5px 10px;font-weight: bold;'>每日新闻</h3></div>";
            for(var i=0;i<list.length;i++){

                str += "<div style='width: 100%;height: 60px'>"
                str += "<div class='news' style='float: left;width: 98%;margin: 20px 10px'>"
                str += "<div style='float: left;'>"
                str += "<a href='javascript:getContent()' >"
                str += "<img width='250' height='200' src='http://192.168.0.20:8083/img/"+list[i].img+"'/>"
                str += "</a>"
                str += "</div>"
                str += "<div style='float: left;margin: 10px auto'>"
                str += "<h3 style='margin: 4px 4px'><a href='#' target='_blank'>"+list[i].title+"</a></h3>"
                str += " <p style='margin: 10px 4px'>"+list[i].shortDesc+"</p>"
                str += " <p style='margin-top: 60px'>"+list[i].publicTime+"</p>"
                str += "</div>"
                str += "</div>"
                str += "</div>"
            }
            $("#newsIds").html(str)
        }
    });

})
function getContent() {
    alert(1111)
}

